<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>题库管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="__PUBLIC__/BeginnerAdmin/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="__PUBLIC__/BeginnerAdmin/css/global.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/BeginnerAdmin/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="__PUBLIC__/BeginnerAdmin/css/table.css" />
</head>
<body>
    <form>
        <div class="admin-main">

            <blockquote class="layui-elem-quote">
                <a href="javascript:;" class="layui-btn" id="add"onclick="NewLibraryUI();">
                    <i class="layui-icon">&#xe608;</i> 添加题库
                </a>
                <div class="layui-inline">
                    <label class="layui-form-label"></label>
                    <div class="layui-input-inline">
                        <input type="text" name="so" lay-verify="so" autocomplete="off" class="layui-input" placeholder="请输入要搜索的内容">
                    </div>
                <a href="javascript:;" class="layui-btn" id="search">
                    <i class="layui-icon">&#xe615;</i> 搜索
                </a>
            </blockquote>
            <fieldset class="layui-elem-field">
                <legend>题库管理</legend>
                <div class="layui-field-box layui-form">
                    <table class="layui-table admin-table">
                        <thead>
                        <tr>
                            <th style="width: 30px;"><input type="checkbox" lay-filter="allselector" lay-skin="primary"></th>
                            <th>名称</th>
                            <th>学科</th>
                            <th>年级</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="content">
                        <foreach name="examination_list" item="v" key="k">
                            <tr>
                                <th><{$v.examinationid}></th>
                                <td><{$v.title}></td>
                                <td><{$v.subject_name}></td>
                                <td><{$v.gradename}></td>
                                <td>
                                    <if condition="$v.status eq 0">
                                        停用
                                        <elseif condition="$v.status eq 1"/>
                                        启用
                                        <else />
                                    </if>
                                </td>
                                <td>
                                    <div class="layui-btn-group">
                                        <a class="layui-btn" onclick='newlibtab("<{:U('topic/Manage',array('examinationid'=>$v['examinationid']))}>","题库编辑-<{$v.examinationid}>")'>
                                            <i class="layui-icon">&#xe705;</i>
                                        </a>
                                        <a class="layui-btn" onclick="edit('<{$v.examinationid}>');">
                                            <i class="layui-icon">&#xe642;</i>
                                        </a>
                                        <a class="layui-btn" onclick="DeleteLibrary('<{$v.examinationid}>')">
                                            <i class="layui-icon">&#xe640;</i>
                                        </a>
                                    </div>
                                </td>
                            </tr>
                        </foreach>
                        </tbody>
                    </table>
                </div>

                <div class="layui-inline" style="Float:right;display:inline;" align="right">
                    <div class="layui-input-inline" style="width: 63px;">
                        <input type="number" id="page" name="page" style="height:30px;width: 60px;" autocomplete="off" class="layui-input" value="<{$page}>">
                    </div>
                    <a class="layui-btn layui-btn-small" href="javascript:;" onclick="page();">
                        <i class="layui-icon">&#xe609;</i>
                    </a>
                </div>


                <div id="pagediv" style="Float:right;" class="layui-btn-group" align="right">
                    <a class="layui-btn layui-btn-small layui-btn-primary">第<{$page}>页,总<{$count}>页</a>
                    <a class="layui-btn layui-btn-small" href="<{:U('Library/Manage',array(page=>$page-1))}>">
                        <i class="layui-icon">&#xe603;</i>
                        <a class="layui-btn layui-btn-small" href="<{:U('Library/Manage',array(page=>$page+1))}>">
                            <i class="layui-icon">&#xe602;</i>
                        </a>
                </div>
            </fieldset>
            <div class="admin-table-page">
                <div id="paged" class="page">

                </div>
            </div>
        </div>
    </form>
    <script type="text/javascript" src="__PUBLIC__/BeginnerAdmin/plugins/layui/layui.js"></script>
    <script src="__PUBLIC__/AmazeUI/assets/js/jquery-1.8.0.min.js"></script>

    <script>
        layui.use('layer', function() {
        var $ = layui.jquery, layer = layui.layer;
        });
        function edit(id) {
            layer.open({
                title: '修改信息',
                maxmin: false,
                type: 2,
                id:1,
                content: 'Admin_Library_EditLibrary.html?libraryid='+id,
                area: ['400px', '500px'],
                end:function (index, layero) {
                    settime();
                }
            });
        }
        function settime() {
            location.reload(true);
        }

        function NewLibraryUI() {
            layer.open({
                title: '添加题库',
                maxmin: false,
                type: 2,
                id:1,
                content: 'Admin_Library_NewLibraryUI.html',
                area: ['400px', '500px'],
                end:function (index, layero) {
                    settime();
                }
            });
        }

        function newlibtab(url,titles) {
            parent.tab.tabAdd({
                href: url, //地址
                icon: '&#xe63c;',
                title:titles
            });
        }


        function DeleteLibrary(id) {
            layer.open({
                title: '删除题库',
                maxmin: false,
                type: 1,
                id:1,
                resize:false,
                content: '<div align="center">确定删除该题库？</div>',
                btn:['确定','取消'],
                btn1:function (index,layero) {
                    $.post('Admin_Library_DeleteLibrary.html',
                        {libraryid:id},
                        function (date) {
                            if(date.code == 200){
                                layer.msg('删除成功！');
                                setTimeout('settime()', 1500);//延时执行，让人看得更清楚
                            }else{
                                layer.alert('删除失败！');
                            }
                        },'json');
                    layer.close(index);
                },
                btn2:function (index,layero) {
                }
            });
        }

        function page() {
            window.location.href="Admin_Library_Manage.html?page="+$("#page").val();
        }
    </script>
</body>
</html>